package com.teacold.customdemo.chapter_thirteen;

import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;

public class MySimpleGestureListener extends GestureDetector.SimpleOnGestureListener {
    final int FLING_MIN_DISTANCE=100,FLING_MIN_VELOCITY=200;


    @Override
    public boolean onDown(MotionEvent e) {
        Log.e("GGGGGGG","onDown");
        return false;
    }

    @Override
    public void onShowPress(MotionEvent e) {
        Log.e("GGGGGGG","onShowPress");
    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        Log.e("GGGGGGG","onSingleTapUp");
        return true;
    }

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        Log.e("GGGGGGG","onScroll");
        return true;
    }

    @Override
    public void onLongPress(MotionEvent e) {
        Log.e("GGGGGGG","onLongPress");
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        Log.e("GGGGGGG","onFling");
        if(e1.getX()-e2.getX()>FLING_MIN_DISTANCE&&Math.abs(velocityX)>FLING_MIN_VELOCITY){
            Log.e("GGGGGGG","向左滑");
        }else if (e2.getX()-e1.getX()>FLING_MIN_DISTANCE&&Math.abs(velocityX)>FLING_MIN_VELOCITY){
            Log.e("GGGGGGG","向右滑");
        }
        return true;
    }

    @Override
    public boolean onSingleTapConfirmed(MotionEvent e) {
        Log.e("GGGGGGG","onSingleTapConfirmed");
        return true;
    }

    @Override
    public boolean onDoubleTap(MotionEvent e) {
        Log.e("GGGGGGG","onDoubleTap");
        return true;
    }

    @Override
    public boolean onDoubleTapEvent(MotionEvent e) {
        Log.e("GGGGGGG","onDoubleTapEvent");
        return true;
    }


}
